<?php
/**
 * Created by PhpStorm.
 * User: yangfan
 * Date: 2019/11/27
 * Time: 2:44 PM
 */

namespace App\BO\OrderStatus\State;

use App\BO\OrderStatus\Events\OrderCreateSuccessEvent;
use App\BO\OrderStatus\OrderStateContext;

class BeforeInitState extends AOrderState
{
    protected $desc = '末初始化状态';

    /**
     * 将订单设置为待支付状态
     */
    public function init()
    {
        // 将订单状态设置为待支付
        $this->orderStateModifyStore->toWaitingPay();
        $this->stateContext->setOrderState(OrderStateContext::getInstance(PendingState::class));

        event(new OrderCreateSuccessEvent($this->getOrder()));
    }
}
